package debtbundler.domain.bll;

import java.io.Serializable;

import debtbundler.domain.entity.SharedCost;
import debtbundler.domain.entity.Person;

/**
 * A pair consisting of person and a shared sharedCost. Equality and 
 * hash code are based on the entities.
 *  
 * @author Anssi
 *
 */
public class PersonSharedCostPair implements Serializable {
	private static final long serialVersionUID = 1L;
	
	private Person person;
	private SharedCost sharedCost;
	
	public PersonSharedCostPair(Person person, SharedCost sharedCost) {
		this.person = person;
		this.sharedCost = sharedCost;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((person == null) ? 0 : person.hashCode());
		result = prime * result + ((sharedCost == null) ? 0 : sharedCost.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		
		PersonSharedCostPair other = (PersonSharedCostPair) obj;
		if (person == null) {
			if (other.person != null)
				return false;
		} else if (!person.equals(other.person))
			return false;
		if (sharedCost == null) {
			if (other.sharedCost != null)
				return false;
		} else if (!sharedCost.equals(other.sharedCost))
			return false;
		
		return true;
	}

	public Person getPerson() {
		return person;
	}

	public SharedCost getSharedCost() {
		return sharedCost;
	}

	public void setPerson(Person person) {
		this.person = person;
	}

	public void setSharedCost(SharedCost sharedCost) {
		this.sharedCost = sharedCost;
	}
	
	
	
	
}
